// 辅助函数前面填充0
function padStart(num) {
	return (num + '').padStart(2, '0')
}

/**
 * 13位时间戳变为本地时间date模式，而没有time -> "2000-12-13"
 */
export function timestampToLocal(timestamp, showTime = false) {
	const time = new Date(+timestamp)
	const dateStr = `${padStart(time.getFullYear())}-${padStart(time.getMonth() + 1)}-${padStart(time.getDay())}`
	if (showTime) {
		return (
			dateStr +
			'  ' +
			padStart(time.getHours()) +
			':' +
			padStart(time.getMinutes()) +
			':' +
			padStart(time.getSeconds())
		)
	} else {
		return dateStr
	}
}
